import java.security.MessageDigest

class PasswordCodec {
    static encode = { text ->
        MessageDigest md = MessageDigest.getInstance('SHA-1')
        md.update(text.getBytes('UTF-8'))
        byte[] data = md.digest()
        StringBuilder sb = new StringBuilder(40)
        for (int value in data) {
            value &= 0xFF
            if (value < 0x10) {
                sb.append("0")
            }
            sb.append(Integer.toString(value, 16))
        }
        sb.toString()
    }
}